﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="jqformValidator_demo.aspx.cs" Inherits="test_jqformValidator_demo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>form表单验证</title>
    <script src="../js/jquery-1.3.2.min.js" type="text/javascript"></script>
<link type="text/css" rel="stylesheet" href="../css/validator.css"></link>
<script src="../js/formValidator.js" type="text/javascript" charset="UTF-8"></script>
<script src="../js/formValidatorRegex.js" type="text/javascript" charset="UTF-8"></script>
<script language="javascript" src="../datepicker/WdatePicker.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function()
{
	$.formValidator.initConfig({onerror:function(msg){alert(msg)},onsuccess:function(){alert('1组测试通过');return false;}});
	$("#uname").formValidator({onshow:"请输入用户名！",onfocus:"请输入6位以上！",oncorrect:"可以注册!"}).inputValidator({min:6,empty:{leftempty:false,rightempty:false,emptyerror:"左右不能为空!"},onerror:"用户名不能小于6位!"})/*.ajaxValidator({
		type:"get",
		url:"Default.aspx",
		success:function(){alert("恭喜可以注册")},
		error: function(){alert("服务器没有返回数据，可能服务器忙，请重试");},
		onerror : "该用户名不可用，请更换用户名",
		onwait : "正在对用户名进行合法性校验，请稍候..."
	})*/;
	$.formValidator.initConfig({validatorgroup:"2",onerror:function(msg){alert(msg)},onsuccess:function(){alert('2组测试通过');return false;}});
	$("#upwd").formValidator({validatorgroup:"2",onshow:"请输入密码！",onfocus:"密码必须6-10位！",oncorrect:"密码格式正确！"}).inputValidator({min:6,max:10,onerror:"密码必须6-10位！"});
	$("#upwd1").formValidator({validatorgroup:"2",onshow:"请输入密码！",onfocus:"密码必须6-10位！",oncorrect:"密码一致！"}).inputValidator({min:6,max:10,onerror:"密码必须6-10位！"}).compareValidator({desid:"upwd",operateor:"=",onerror:"密码输入不一致！"});
	$("#dt").focus(
	function()
		{WdatePicker({skin:'whyGreen',oncleared:function(){$(this).blur();},onpicked:function(){$(this).blur();}}
	)
	});
});

function test1(){
return jQuery.formValidator.pageIsValid('1');
}
function test2(){
return jQuery.formValidator.pageIsValid('2');
}
</script>
</head>
<body>
     <form id="form1">
	<table>
		<tr>
			<td><input type="text" id="uname" width="150px"></td>
			<td><div id="unameTip"></div></td>
		</tr>
		<tr>
			<td><input type="password" id="upwd" width="150px"></td>
			<td><div id="upwdTip"></div></td>
		</tr>
		<tr>
			<td><input type="password" id="upwd1" width="150px"></td>
			<td><div id="upwd1Tip"></div></td>
		</tr>
		<tr>
			<td><input type="text" id="dt" width="150px"></td>
			<td><div id="dtTip"></div></td>
		</tr>
		<tr>
			<td><input type="button" id="btn1" style="width:100px; height:25px;" onclick="return test1()" value="验证1组"/>
			<input type="button" id="btn2" style="width:100px; height:25px;" onclick="return test2()" value="验证2组"/>
			</td>
		</tr>
	</table>
  </form>
</body>
</html>
